/**
 * Created by wd14931 on 2017/6/5.
 */
var tpl = require('./../../template/purchase_management/preview.html');

var userList = [
    {
        'BillNumber': '13we4ADSAD34',
        'PurchaseStatus': '审核中',
        'Supplier': '苹果实业有限公司',
        'PurchaseType': '补货',
        'PurchaseMoney': '129901.897',
        'Purchaser': '张三'
    },{
        'BillNumber': '13we4ADSAD34',
        'PurchaseStatus': '审核中',
        'Supplier': '苹果实业有限公司',
        'PurchaseType': '补货',
        'PurchaseMoney': '129901.897',
        'Purchaser': '张三'
    },{
        'BillNumber': '13we4ADSAD34',
        'PurchaseStatus': '审核中',
        'Supplier': '苹果实业有限公司',
        'PurchaseType': '补货',
        'PurchaseMoney': '129901.897',
        'Purchaser': '张三'
    },{
        'BillNumber': '13we4ADSAD34',
        'PurchaseStatus': '审核中',
        'Supplier': '苹果实业有限公司',
        'PurchaseType': '补货',
        'PurchaseMoney': '129901.897',
        'Purchaser': '张三'
    },{
        'BillNumber': '13we4ADSAD34',
        'PurchaseStatus': '审核中',
        'Supplier': '苹果实业有限公司',
        'PurchaseType': '补货',
        'PurchaseMoney': '129901.897',
        'Purchaser': '张三'
    },{
        'BillNumber': '13we4ADSAD34',
        'PurchaseStatus': '审核中',
        'Supplier': '苹果实业有限公司',
        'PurchaseType': '补货',
        'PurchaseMoney': '129901.897',
        'Purchaser': '张三'
    },{
        'BillNumber': '13we4ADSAD34',
        'PurchaseStatus': '审核中',
        'Supplier': '苹果实业有限公司',
        'PurchaseType': '补货',
        'PurchaseMoney': '129901.897',
        'Purchaser': '张三'
    },{
        'BillNumber': '13we4ADSAD34',
        'PurchaseStatus': '审核中',
        'Supplier': '苹果实业有限公司',
        'PurchaseType': '补货',
        'PurchaseMoney': '129901.897',
        'Purchaser': '张三'
    },{
        'BillNumber': '13we4ADSAD34',
        'PurchaseStatus': '审核中',
        'Supplier': '苹果实业有限公司',
        'PurchaseType': '补货',
        'PurchaseMoney': '129901.897',
        'Purchaser': '张三'
    },{
        'BillNumber': '13we4ADSAD34',
        'PurchaseStatus': '审核中',
        'Supplier': '苹果实业有限公司',
        'PurchaseType': '补货',
        'PurchaseMoney': '129901.897',
        'Purchaser': '张三'
    },{
        'BillNumber': '13we4ADSAD34',
        'PurchaseStatus': '审核中',
        'Supplier': '苹果实业有限公司',
        'PurchaseType': '补货',
        'PurchaseMoney': '129901.897',
        'Purchaser': '张三'
    },
];
var purchaseInfo = {
    'BillDay': '预期',
    'BillNumber': '13we4ADSAD34',
    'Supplier': '苹果实业有限公司',
    'PurchaseType': '网购',
    'DefaultLib': '仓库1号',
    'Purchaser': '张三',
    'PurchaserDepartment': '运输部',
    'PurchaserTransport': '火车',
    'TaxRate': '13%',
    'Discount': '22%'
};
// title
var operate = ['货号','商品名称','总数量	','单价	','采购价格	','预计到货时间','备注','操作'];
var productList = [
    {
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {'颜色/尺码':[23,34,56,78,12,45,28,28]},
            {'黑色':[00,34,56,78,12,45,28,28]},
            {'白色':[23,34,56,78,12,45,28,28]},
            {'蓝色':[23,34,56,78,12,45,28,28]},
            {'墨绿':[23,34,56,78,12,45,28,28]},
            {'黑绿':[23,34,56,78,12,45,28,28]},
            {'西瓜绿':[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {'颜色/尺码':[23,34,56,78,12,45,28,28]},
            {'黑色':[00,34,56,78,12,45,28,28]},
            {'白色':[23,34,56,78,12,45,28,28]},
            {'蓝色':[23,34,56,78,12,45,28,28]},
            {'墨绿':[23,34,56,78,12,45,28,28]},
            {'黑绿':[23,34,56,78,12,45,28,28]},
            {'西瓜绿':[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {'颜色/尺码':[23,34,56,78,12,45,28,28]},
            {'黑色':[00,34,56,78,12,45,28,28]},
            {'白色':[23,34,56,78,12,45,28,28]},
            {'蓝色':[23,34,56,78,12,45,28,28]},
            {'墨绿':[23,34,56,78,12,45,28,28]},
            {'黑绿':[23,34,56,78,12,45,28,28]},
            {'西瓜绿':[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {'颜色/尺码':[23,34,56,78,12,45,28,28]},
            {'黑色':[00,34,56,78,12,45,28,28]},
            {'白色':[23,34,56,78,12,45,28,28]},
            {'蓝色':[23,34,56,78,12,45,28,28]},
            {'墨绿':[23,34,56,78,12,45,28,28]},
            {'黑绿':[23,34,56,78,12,45,28,28]},
            {'西瓜绿':[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {'颜色/尺码':[23,34,56,78,12,45,28,28]},
            {'黑色':[00,34,56,78,12,45,28,28]},
            {'白色':[23,34,56,78,12,45,28,28]},
            {'蓝色':[23,34,56,78,12,45,28,28]},
            {'墨绿':[23,34,56,78,12,45,28,28]},
            {'黑绿':[23,34,56,78,12,45,28,28]},
            {'西瓜绿':[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {'颜色/尺码':[23,34,56,78,12,45,28,28]},
            {'黑色':[00,34,56,78,12,45,28,28]},
            {'白色':[23,34,56,78,12,45,28,28]},
            {'蓝色':[23,34,56,78,12,45,28,28]},
            {'墨绿':[23,34,56,78,12,45,28,28]},
            {'黑绿':[23,34,56,78,12,45,28,28]},
            {'西瓜绿':[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {'颜色/尺码':[23,34,56,78,12,45,28,28]},
            {'黑色':[00,34,56,78,12,45,28,28]},
            {'白色':[23,34,56,78,12,45,28,28]},
            {'蓝色':[23,34,56,78,12,45,28,28]},
            {'墨绿':[23,34,56,78,12,45,28,28]},
            {'黑绿':[23,34,56,78,12,45,28,28]},
            {'西瓜绿':[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {'颜色/尺码':[23,34,56,78,12,45,28,28]},
            {'黑色':[00,34,56,78,12,45,28,28]},
            {'白色':[23,34,56,78,12,45,28,28]},
            {'蓝色':[23,34,56,78,12,45,28,28]},
            {'墨绿':[23,34,56,78,12,45,28,28]},
            {'黑绿':[23,34,56,78,12,45,28,28]},
            {'西瓜绿':[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {'颜色/尺码':[23,34,56,78,12,45,28,28]},
            {'黑色':[00,34,56,78,12,45,28,28]},
            {'白色':[23,34,56,78,12,45,28,28]},
            {'蓝色':[23,34,56,78,12,45,28,28]},
            {'墨绿':[23,34,56,78,12,45,28,28]},
            {'黑绿':[23,34,56,78,12,45,28,28]},
            {'西瓜绿':[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {name: '颜色/尺码', list:[23,34,56,78,12,45,28,28]},
            {name: '黑色', list:[00,34,56,78,12,45,28,28]},
            {name: '白色', list:[23,34,56,78,12,45,28,28]},
            {name: '蓝色', list:[23,34,56,78,12,45,28,28]},
            {name: '墨绿', list:[23,34,56,78,12,45,28,28]},
            {name: '黑绿', list:[23,34,56,78,12,45,28,28]},
            {name: '西瓜绿', list:[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {name: '颜色/尺码', list:[23,34,56,78,12,45,28,28]},
            {name: '黑色', list:[00,34,56,78,12,45,28,28]},
            {name: '白色', list:[23,34,56,78,12,45,28,28]},
            {name: '蓝色', list:[23,34,56,78,12,45,28,28]},
            {name: '墨绿', list:[23,34,56,78,12,45,28,28]},
            {name: '黑绿', list:[23,34,56,78,12,45,28,28]},
            {name: '西瓜绿', list:[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {name: '颜色/尺码', list:[23,34,56,78,12,45,28,28]},
            {name: '黑色', list:[00,34,56,78,12,45,28,28]},
            {name: '白色', list:[23,34,56,78,12,45,28,28]},
            {name: '蓝色', list:[23,34,56,78,12,45,28,28]},
            {name: '墨绿', list:[23,34,56,78,12,45,28,28]},
            {name: '黑绿', list:[23,34,56,78,12,45,28,28]},
            {name: '西瓜绿', list:[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {name: '颜色/尺码', list:[23,34,56,78,12,45,28,28]},
            {name: '黑色', list:[00,34,56,78,12,45,28,28]},
            {name: '白色', list:[23,34,56,78,12,45,28,28]},
            {name: '蓝色', list:[23,34,56,78,12,45,28,28]},
            {name: '墨绿', list:[23,34,56,78,12,45,28,28]},
            {name: '黑绿', list:[23,34,56,78,12,45,28,28]},
            {name: '西瓜绿', list:[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {name: '颜色/尺码', list:[23,34,56,78,12,45,28,28]},
            {name: '黑色', list:[00,34,56,78,12,45,28,28]},
            {name: '白色', list:[23,34,56,78,12,45,28,28]},
            {name: '蓝色', list:[23,34,56,78,12,45,28,28]},
            {name: '墨绿', list:[23,34,56,78,12,45,28,28]},
            {name: '黑绿', list:[23,34,56,78,12,45,28,28]},
            {name: '西瓜绿', list:[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {name: '颜色/尺码', list:[23,34,56,78,12,45,28,28]},
            {name: '黑色', list:[00,34,56,78,12,45,28,28]},
            {name: '白色', list:[23,34,56,78,12,45,28,28]},
            {name: '蓝色', list:[23,34,56,78,12,45,28,28]},
            {name: '墨绿', list:[23,34,56,78,12,45,28,28]},
            {name: '黑绿', list:[23,34,56,78,12,45,28,28]},
            {name: '西瓜绿', list:[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {name: '颜色/尺码', list:[23,34,56,78,12,45,28,28]},
            {name: '黑色', list:[00,34,56,78,12,45,28,28]},
            {name: '白色', list:[23,34,56,78,12,45,28,28]},
            {name: '蓝色', list:[23,34,56,78,12,45,28,28]},
            {name: '墨绿', list:[23,34,56,78,12,45,28,28]},
            {name: '黑绿', list:[23,34,56,78,12,45,28,28]},
            {name: '西瓜绿', list:[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {name: '颜色/尺码', list:[23,34,56,78,12,45,28,28]},
            {name: '黑色', list:[00,34,56,78,12,45,28,28]},
            {name: '白色', list:[23,34,56,78,12,45,28,28]},
            {name: '蓝色', list:[23,34,56,78,12,45,28,28]},
            {name: '墨绿', list:[23,34,56,78,12,45,28,28]},
            {name: '黑绿', list:[23,34,56,78,12,45,28,28]},
            {name: '西瓜绿', list:[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {name: '颜色/尺码', list:[23,34,56,78,12,45,28,28]},
            {name: '黑色', list:[00,34,56,78,12,45,28,28]},
            {name: '白色', list:[23,34,56,78,12,45,28,28]},
            {name: '蓝色', list:[23,34,56,78,12,45,28,28]},
            {name: '墨绿', list:[23,34,56,78,12,45,28,28]},
            {name: '黑绿', list:[23,34,56,78,12,45,28,28]},
            {name: '西瓜绿', list:[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    },{
        ProductId    : '123',
        ProductName  : '123',
        ProductCountInfo:[
            {name: '颜色/尺码', list:[23,34,56,78,12,45,28,28]},
            {name: '黑色', list:[00,34,56,78,12,45,28,28]},
            {name: '白色', list:[23,34,56,78,12,45,28,28]},
            {name: '蓝色', list:[23,34,56,78,12,45,28,28]},
            {name: '墨绿', list:[23,34,56,78,12,45,28,28]},
            {name: '黑绿', list:[23,34,56,78,12,45,28,28]},
            {name: '西瓜绿', list:[23,34,56,78,12,45,28,28]}
        ],
        UnitPrice    : '123.40',
        PurchasePrice: '122.40',
        EstimatedTime: '2017-6-11 12:20:08',
        Remarks       : '撒的客户尽快'
    }
];

module.exports = {
    template: tpl,

    data: function(){
        return {
            name: 'purchase-preview',
            data: {},
            purchaseInfo: {},
            operate: {},
            productList: {}
        };
    },
    // 组件创建完成
    created: function() {
        ss = this;
        // 此时 data 已经被 observed 了
        this.fetchData();
    },
    mounted:function(){

        $(document.querySelector('.scroll-purchase-preview')).niceScroll(
        {
            cursorcolor:"#989494",
            cursoropacitymax:1,
            touchbehavior:false,
            cursorwidth:"3px",
            cursorborder:"0",
            cursorborderradius:"5px"
        });

        $(document.querySelector('.purchase-product-list')).niceScroll(
        {
            cursorcolor:"#989494",
            cursoropacitymax:1,
            touchbehavior:false,
            cursorwidth:"3px",
            cursorborder:"0",
            cursorborderradius:"5px"
        });

    },
    // router change fetch data again
    watch: {
        '$route': 'fetchData'
    },
    // 滚动
    scrollBehavior: function(to, from, savedPosition) {
        return { x: 0, y: 0 }
    },
    methods:{

        // fetch data from service
        fetchData: function(){
            this.data          = userList;
            this.purchaseInfo = purchaseInfo;
            this.operate       = operate;
            this.productList   = productList;
        },

        sortList: function(key){
            console.log(this.data.length)
        }
    }
};